<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


include './UsuarioClass.php';
include_once '../view/component/datagrid/TableGridClass.php';

$usuarios_encontrados = UsuarioClass::PESQUISAR($_POST['nome'],$_POST['cpf']);

$tableHead = "
    <thead>
      <tr>
      <td>Nome</td><td>CPF</td><td>E-mail</td>
      </tr>
    </thead>
      ";

$usuarios = new ArrayIterator($usuarios_encontrados);
$tableContent = "<tbody>";
while ($usuarios->valid()):
    $tableContent = $tableContent . "<tr>";
    $tableContent = $tableContent .
            "<td>" . $usuarios->current()->nome . "</td>" .
            "<td>" . $usuarios->current()->cpf . "</td>" .
            "<td>" . $usuarios->current()->email . "</td>";
    $tableContent = $tableContent . "</tr>";
    $usuarios->next();

endwhile;

$tableContent=$tableContent."</tbody>";
$content=$tableHead.$tableContent;

$tbGrid= new TableGridClass();

$tbGrid->setTableTitle("Resultado Pesquisa");
$tbGrid->setTableContent($content);
$tbGrid->keepTableGrid();


header('Location: ' . $_SERVER['HTTP_REFERER']);

